package com.analyse.stock.model;

import com.analyse.stock.enums.IndexCategoryEnum;
import com.analyse.stock.enums.MarketEnum;
import com.analyse.stock.vo.FinanceDataVO;
import com.analyse.stock.vo.TickerVO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("t_index_info")
public class IndexInfoModel extends BaseModel<IndexInfoModel> {

    //指数代码
    private String indexCode;

    //指数名称
    private String indexName;

    //国家或地区代码
    private String countryCode;

    private String markCode;
    private String shortMarkCode;

    public static IndexInfoModel transIndexInfoModel(TickerVO vo){
        IndexInfoModel model = new IndexInfoModel();
        model.setIndexCode(vo.getTicker());
        model.setIndexName(vo.getName());
        model.setCountryCode(vo.getCountryCode());
        model.setUpdateTime(new Date());
        model.setCreateTime(new Date());
        return model;
    }

    public static IndexInfoModel transIndexInfoModel(FinanceDataVO vo, IndexCategoryEnum categoryEnum,String countryCode){
        IndexInfoModel model = new IndexInfoModel();
        model.setIndexCode(vo.getF12());
        model.setIndexName(vo.getF14());
        model.setCountryCode(countryCode);
        model.setShortMarkCode(categoryEnum.getShortMarkCodee());
        model.setMarkCode(categoryEnum.getMarkCodee());
        model.setUpdateTime(new Date());
        model.setCreateTime(new Date());
        return model;
    }
}
